home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #9 / Amiga Plus CD - 2004 - No. 09.iso / amigaplus / tools / dev_libs / feelin040718 / sources / gauge / prefs.c < prev    next >
C/C++ Source or Header  |  2004-08-03  |  4KB  |  144 lines

  1. #include "Private.h"
  2.  
  3. #define DEF_GAUGE_BACK                           NULL
  4. #define DEF_GAUGE_FRAME                          "0:12.0"
  5.  
  6. #include <proto/exec.h>
  7. #define SysBase   FeelinBase -> SYS
  8.  
  9. /*** Private ***************************************************************/
  10.  
  11. ///VLabel_
  12. FObject VLabel_(STRPTR Name)
  13. {
  14.    return   TextObject,
  15.             FA_SetMax,           FV_SetMaxH,
  16.             FA_ChainToCycle,     FALSE,
  17.             FA_Text,             Name,
  18.             FA_Text_HCenter,     TRUE,
  19.             End;
  20. }
  21. //+
  22.  
  23. /*** Methods ***************************************************************/
  24.  
  25. ///p_Gauge_New
  26. F_METHOD(ULONG,p_Gauge_New)
  27. {
  28.    struct p_LocalObjectData *LOD = F_LOD(Class,Obj);
  29.  
  30.    LOD -> AreaData = (FAreaData *) F_Get(Obj,FA_AreaData);
  31.  
  32.    LOD -> Val                       = 1;
  33.    LOD -> SignalHandler.Object      = Obj;
  34.    LOD -> SignalHandler.Method      = FM_Gauge_Update,
  35.    LOD -> SignalHandler.Flags       = FF_SignalHandler_Timer;
  36.    LOD -> SignalHandler.fsh_Secs    = 0;
  37.    LOD -> SignalHandler.fsh_Micros  = 30000;
  38.  
  39.    return F_SuperDo(Class,Obj,Method,
  40.  
  41.       FA_ChainToCycle,     FALSE,
  42.       FA_Group_Title,      "Gauge",
  43.  
  44.       Child, ColGroup(2),
  45.          Child, LOD -> g_frame = PopFrameObject, End,
  46.          Child, LOD -> g_back  = PopImageObject, End,
  47.          Child, VLabel_("Frame"),
  48.          Child, VLabel_("Back"),
  49.       End,
  50.  
  51.       Child, VGroup, GroupFrame, FA_Frame_Title, "Example",
  52.          Child, LOD -> g_gauge = GaugeObject,
  53.             FA_Frame,           "FP_Gauge_Frame",
  54.             FA_Back,            "FP_Gauge_Back",
  55.             FA_Horizontal,       TRUE,
  56.             FA_SetMax,           FV_SetMaxH,
  57.             FA_ChainToCycle,     FALSE,
  58.            "FA_Numeric_Max",     100,
  59.          End,
  60.       End,
  61.  
  62.    TAG_MORE,Msg);
  63. }
  64. //+
  65. ///p_Gauge_Load
  66. F_METHODM(void,p_Gauge_Load,FS_PreferenceGroup_Load)
  67. {
  68.    struct p_LocalObjectData *LOD = F_LOD(Class,Obj);
  69.  
  70.    ULONG    data,
  71.             idFrm = F_DynamicFindID("FA_PopFrame_Spec"),
  72.             idImg = F_DynamicFindID("FA_PopImage_Spec");
  73.  
  74.    data = F_Do(Msg -> Prefs,Msg -> id_Resolve,"FP_Gauge_Back",   DEF_GAUGE_BACK);    F_Set(LOD -> g_back,  idImg,data);
  75.    data = F_Do(Msg -> Prefs,Msg -> id_Resolve,"FP_Gauge_Frame",  DEF_GAUGE_FRAME);   F_Set(LOD -> g_frame, idFrm,data);
  76. }
  77. //+
  78. ///p_Gauge_Save
  79. F_METHODM(void,p_Gauge_Save,FS_PreferenceGroup_Save)
  80. {
  81.    struct p_LocalObjectData *LOD = F_LOD(Class,Obj);
  82.  
  83.    ULONG       data,
  84.                idFrm = F_DynamicFindID("FA_PopFrame_Spec"),
  85.                idImg = F_DynamicFindID("FA_PopImage_Spec");
  86.  
  87.    data = F_Get(LOD -> g_back,   idImg);  F_Do(Msg -> Prefs,Msg -> id_AddString, "FP_Gauge_Back", data);
  88.    data = F_Get(LOD -> g_frame,  idFrm);  F_Do(Msg -> Prefs,Msg -> id_AddString, "FP_Gauge_Frame",data);
  89. }
  90. //+
  91. ///p_Gauge_Show
  92. F_METHOD(ULONG,p_Gauge_Show)
  93. {
  94.    struct p_LocalObjectData *LOD = F_LOD(Class,Obj);
  95.  
  96.    if (_render)
  97.    {
  98.       F_Do(_app,FM_Application_AddSignalHandler,&LOD -> SignalHandler);
  99.    }
  100.  
  101.    return F_SUPERDO();
  102. }
  103. //+
  104. ///p_Gauge_Hide
  105. F_METHOD(void,p_Gauge_Hide)
  106. {
  107.    struct p_LocalObjectData *LOD = F_LOD(Class,Obj);
  108.  
  109.    F_SUPERDO();
  110.  
  111.    if (_render)
  112.    {
  113.       F_Do(_app,FM_Application_RemSignalHandler,&LOD -> SignalHandler);
  114.    }
  115. }
  116. //+
  117. ///p_Gauge_Update
  118. F_METHOD(LONG,p_Gauge_Update)
  119. {
  120.    struct p_LocalObjectData *LOD = F_LOD(Class,Obj);
  121.    LONG                    min,max,val;
  122.  
  123.    F_Do(LOD -> g_gauge,FM_Get,
  124.                  F_IDO(p_FA_Numeric_Min), &min,
  125.                  F_IDO(p_FA_Numeric_Max), &max, TAG_DONE);
  126.  
  127.    val = F_Do(LOD -> g_gauge,F_IDO(p_FM_Numeric_Increase),LOD -> Val);
  128.  
  129. //   F_DebugOut("Val %ld - Min %ld - Max %ld\n",val,min,max);
  130.  
  131.    if (val == min)
  132.    {
  133.       LOD -> Val = 1;
  134.    }
  135.    else if (val == max)
  136.    {
  137.       LOD -> Val = -1;
  138.    }
  139.  
  140.    return TRUE; // If we return FALSE the timer event won't be requested again
  141. }
  142. //+
  143.  
  144.